
		**********************************************************
		** File: cleaning_IPI.do								**
		** Paper: Human Trafficking Indicators: A New Dataset	**
		** Author: Richard Frank								**
		** Date: July 11, 2021									**
		** Task: Cleaning IPI peacekeeping data					**
 		**********************************************************
 

		clear all
		version 16.1
		set seed 1234
 
		cd "~"
 
		** Data from: https://www.ipinst.org/providing-for-peacekeeping-database
		
		import delimited "data_tcc.csv", clear 
		rename contributor Country
		run "cow.do"
		sort ccode
		tab Country if ccode==0
		drop if ccode==0
		order Country ccode
		rename Country country
		split date, p(-) gen(temp)
		drop temp2 temp3
		rename temp1 year
		destring year, replace
		order ccode country year
		sort ccode date
		drop date
		collapse (max) total (first) country , by(ccode year)
		rename total peacekeepers
		label var peacekeepers "# of UN peacekeepers sent abroad (IPI)"
		
		save "IPI_peacekeeping.dta", replace
		
		
	*** UN destination country ** 
			
		import delimited "full_data.csv", clear 
		keep mission_country total date contributor
		rename mission_country Country
		run "cow.do"
		sort ccode
		tab Country if ccode==0
		drop if ccode==0
		order Country ccode
		rename Country country
		split date, p(-) gen(temp)
		drop temp2 temp3
		rename temp1 year
		destring year, replace
		order ccode country year
		sort ccode date
		drop date
		replace total="" if total=="NA"
		destring total, replace
		collapse (max) total (first) country , by(ccode year)
		rename total peacekeepers_foreign
		label var peacekeepers_foreign "# of UN peacekeepers in country (IPI)"
		save "IPI_peacekeeping_dest.dta", replace
